package com.cn.wanxi.publisher.domain.model;

import lombok.Data;

/**
 * @ClassName ResultModle
 * @Description 前端结果集
 * @Author JiJiang
 * @Date 2022/9/26 19:08
 * @Version 1.0
 */

@Data
public class ResultModel {


    //返回客户端的标志位
    private Integer code;

    //返回客户端的消息
    private String msg;


    //返回到客户端的受影响的行数
    private Integer count;


    //返回到客户端的数据
    private Object data;


    //region 获取结果集对象

    private static ResultModel getResult(int code, String msg, int count, Object data) {

        ResultModel resultModel = new ResultModel();
        resultModel.setCode(code);
        resultModel.setMsg(msg);
        resultModel.setCount(count);
        resultModel.setData(data);
        return resultModel;

    }


    public static ResultModel getResult(int count) {

        return getResult(0, "", count, "");
    }

    public static ResultModel getResult(String msg) {

        return getResult(0, msg, 0, "");
    }


    public static ResultModel getResult(Object data) {

        return getResult(0, "", 0, data);
    }


    public static ResultModel getResult(String msg, int count) {

        return getResult(0, msg, count, "");
    }

    public static ResultModel getResult(String msg, Object data) {

        return getResult(0, msg, 0, data);
    }

    public static ResultModel getResult(int count, Object data) {

        return getResult(0, "", count, data);
    }


    public static ResultModel getResult(String msg, int count, Object data) {

        return getResult(0, msg, count, data);
    }


    //endregion


    @Override
    public String toString() {
        return "ResultBean{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", count=" + count +
                ", data=" + data +
                '}';
    }
}
